#!/usr/bin/perl
#
# Dirty hack to have bayes_path availible as user defined option.
# needed for multi-domain amavis filtering with per domain bayes-db
# config-option in the sa-config file is now: o_bayes <path>

package Mail::SpamAssassin::Plugin::O_Bayes;

use Mail::SpamAssassin::Plugin;
use strict;
use bytes;
use warnings;
use Data::Dumper;

use vars qw(@ISA);
@ISA = qw(Mail::SpamAssassin::Plugin);

sub new {
    my ($class, $mailsa) = @_;

    # the usual perlobj boilerplate to create a subclass object
    $class = ref($class) || $class;
    my $self = $class->SUPER::new($mailsa);
    bless ($self, $class);

    # register our config options
    $self->set_config($mailsa->{conf});

    # and return the new plugin object
    return $self;
}

sub set_config {
    my ($self, $conf) = @_;
    my @cmds = ();

    push (@cmds, {
        setting => 'o_bayes',
        default => 'bazbar',
        type => $Mail::SpamAssassin::Conf::CONF_TYPE_STRING,
    });


    $conf->{parser}->register_commands(\@cmds);
}

sub finish_parsing_end   {
    my ($self, $params) = @_;

    $params->{conf}->{bayes_path} = $params->{conf}->{o_bayes}."/bayes";

}

1;

# vim: syntax=perl sw=4 ts=4 noet shiftround
